<?php /*a:3:{s:69:"/www/wwwroot/pay.rym.best/application/admin/view/users/agentlist.html";i:1563242534;s:65:"/www/wwwroot/pay.rym.best/application/admin/view/common/head.html";i:1563242522;s:65:"/www/wwwroot/pay.rym.best/application/admin/view/common/foot.html";i:1563242522;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo config('sys_name'); ?>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="/favicon.ico"/>  
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/common/css/font.css" media="all">
</head>
<body class="skin-<?php if(!empty($_COOKIE['skin'])){echo $_COOKIE['skin'];}else{echo '0';setcookie('skin','0');}?>">
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>代理<?php echo lang('user'); ?><?php echo lang('list'); ?></legend>
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <input class="layui-input" name="key" id="key" placeholder="<?php echo lang('pleaseEnter'); ?>关键字">
        </div>
        <button class="layui-btn layui-btn-primary" id="search" data-type="reload">搜索</button>
        <a href="<?php echo url('agentlist'); ?>" class="layui-btn">显示全部</a>
        <a  onclick="openurl('新增码商','<?php echo url('users/add'); ?>','400px','530px')" class="layui-btn layui-btn-normal">新增代理</a>
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/html" id="is_lock">
    <input type="checkbox" name="is_lock" value="{{d.id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="is_lock" {{ d.is_lock == 0 ? 'checked' : '' }}>
</script>
<script type="text/html" id="state">
    <input type="checkbox" name="state" value="{{d.id}}" lay-skin="switch" lay-text="启动|关闭" lay-filter="state" {{ d.state == 0 ? 'checked' : '' }}>
</script>
<script type="text/html" id="action">
    <a href="<?php echo url('user/index/index'); ?>?auid={{d.id}}" target="_blank" class="layui-btn layui-btn-xs">登录</a>
    <div lay-event="channeladd" title="新增通道" class="layui-btn layui-btn-xs">新增通道</div>
    <a href="<?php echo url('edit'); ?>?id={{d.id}}" class="layui-btn layui-btn-xs">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>  
<script type="text/html" id="channel"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="channellist">下级通道</div></script>  
<script type="text/html" id="order"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="orderlist">下级订单</div></script>  
<script type="text/html" id="auserlist"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="auserlist">下级码商</div></script>  
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<script type="text/javascript">
layui.use(['table','form'], function() {
    var table = layui.table,form = layui.form,$ = layui.jquery; 
});
function openurl(title,url,width,height){
	layer.open({
        type: 2,
        title:title,
        shade: 0.5,
        shadeClose: true,
        area: [width,height], 
        content:url,
    });    
}
</script> 


<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: '<?php echo url("agentlist"); ?>',
            method: 'post', 
            page: true,
            cols: [[ 
                {field: 'id', title: '<?php echo lang("id"); ?>', align: 'center',width: 80, fixed: true},
                {field: 'username', title: '姓名',align: 'center', width: 100, fixed: true},
                {field: 'appid', title: 'APPID',align: 'center', width: 100, fixed: true},
                {field: 'mobile', title: '<?php echo lang("tel"); ?>', width: 130}, 
                {field: 'email', title: '<?php echo lang("email"); ?>', width: 170},  
                {field: 'level_name', title: '<?php echo lang("user"); ?><?php echo lang("level"); ?>',align: 'center', width: 100}, 
                {field: 'agentlv', title: '代理手续费',align: 'center', width: 120},  
                {title: '下级码商', align: 'center',width: 100,templet: '#auserlist'}, 
                {title: '下级通道',align: 'center', width: 100,templet: '#channel'}, 
                {title: '下级订单', align: 'center',width: 100,templet: '#order'}, 
                {field: 'is_lock', align: 'center',title: '<?php echo lang("status"); ?>', width: 100,toolbar: '#is_lock'},
                {field: 'state', align: 'center',title: '交易<?php echo lang("status"); ?>', width: 100,toolbar: '#state'},
                {field: 'reg_time', title: '开通时间', width: 147},
                {width: 240, align: 'center', title: '操作', toolbar: '#action', fixed:'right'}
            ]],
            limit: 60 //每页默认显示的数量
        });
        form.on('switch(is_lock)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var is_lock = obj.elem.checked===true?0:1;
            $.post('<?php echo url("usersState"); ?>',{'id':id,'is_lock':is_lock},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });
        form.on('switch(state)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var state = obj.elem.checked===true?0:1;
            $.post('<?php echo url("userstrade"); ?>',{'id':id,'state':state},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });
        //搜索
        $('#search').on('click', function() {
            var key = $('#key').val();
            if($.trim(key)==='') {
                layer.msg('<?php echo lang("pleaseEnter"); ?>关键字！',{icon:0});
                return;
            }
            tableIn.reload({ page: {page: 1},where: {key: key}});
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if(obj.event === 'del') {
                layer.confirm('您确定要删除该码商吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("<?php echo url('usersDel'); ?>",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
            if(obj.event === 'orderlist') {
                layer.open({
                    type: 2,
                    title:'下级订单',
                    shade: 0.5,
                    shadeClose: true,
                    area: ['80%', '90%'], 
                    content:"<?php echo url('order/ordermin'); ?>?agentid="+data.id,
                });    
            }
            if(obj.event === 'channellist') {
                layer.open({
                    type: 2,
                    title:'下级通道',
                    shade: 0.5,
                    shadeClose: true,
                    area: ['80%', '90%'], 
                    content:"<?php echo url('channel/channelmin'); ?>?agentid="+data.id,
                });    
            }
            if(obj.event === 'auserlist') {
                layer.open({
                    type: 2,
                    title:'下级码商',
                    shade: 0.5,
                    shadeClose: true,
                    area: ['80%', '90%'], 
                    content:"<?php echo url('users/auserlist'); ?>?agentid="+data.id,
                });    
            }
            if(obj.event === 'channeladd') {
                layer.open({
                    type: 2,
                    title:'新增通道',
                    shade: 0.5,
                    shadeClose: true,
                    area: ['380px', '344px'], 
                    content:"<?php echo url('channel/addchannel'); ?>?userid="+data.id+"&userlv="+data.userlv,
                });    
            } 
        }); 
    });
</script>
</body>
</html>